package cn.highedu.gateway.demos;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;


import javax.annotation.PostConstruct;

@RefreshScope // 通过该注解，实现配置自动更新
@RestController
public class DemoBean {

    Logger logger = LoggerFactory.getLogger(DemoBean.class);

    @Value("${message}")
    String message;

    @PostConstruct
    public void init(){
        logger.info("Message: {}", message);
    }

    @GetMapping("/message")
    public String message(){
        return message;
    }
}
